#!../../../common/bats/bin/bats
# -*-sh-*-

load ../../../common/test_helper_functions || exit 1
source ../../../common/functions || exit 1

if [ -s ../../../TEST_ENV ];then
    source ../../../TEST_ENV
fi

check_rms
rm=$RESOURCE_MANAGER

NODES=2
TASKS=8
ARGS=8

@test "[libs/TAU] MPI C binary runs under resource manager ($rm/$LMOD_FAMILY_COMPILER/$LMOD_FAMILY_MPI)" {
    if [ ! -s C_mpi_test ];then
	flunk "C_mpi_test binary does not exit"
    fi

    run_mpi_binary ./C_mpi_test $ARGS $NODES $TASKS
    assert_success
}

@test "[libs/TAU] MPI C++ binary runs under resource manager ($rm/$LMOD_FAMILY_COMPILER/$LMOD_FAMILY_MPI)" {
    if [ ! -s CXX_mpi_test ];then
	flunk "CXX_mpi_test binary does not exit"
    fi

    run_mpi_binary ./run_CXX_mpi_test.sh $ARGS $NODES $TASKS
    assert_success
}

@test "[libs/TAU] Serial C OpenMP binary runs under resource manager ($rm/$LMOD_FAMILY_COMPILER/$LMOD_FAMILY_MPI)" {
    if [ ! -s C_omp_test ];then
	flunk "C_omp_test binary does not exit"
    fi

    run_serial_binary ./C_omp_test
    assert_success
}

@test "[libs/TAU] Serial FORTRAN binary runs under resource manager ($rm/$LMOD_FAMILY_COMPILER/$LMOD_FAMILY_MPI)" {
    if [ ! -s F_test ];then
	flunk "F_test binary does not exit"
    fi

    run_serial_binary ./F_test
    assert_success
}
